<?php
/**
 * @author Amissah Gideon<kuulmek@yahoo.com>
 * @access public
 * @version 1.0
 */
?>
<script type="text/javascript">
    var gbl_customers_sales = <?php echo json_encode($customers_sales); ?>;
    //console.log(global_equipment_data);
</script>


<!-- Main content -->
<section role="main" id="main">

    <!-- Header -->
    <?php
        echo $this->element('page_header');
        echo $this->element('navigations/editsale_navbar');
    ?>

    <div class="with-padding">
        <div class="columns">
            <div class="new-row-mobile twelve-columns six-columns-tablet twelve-columns-mobile">

                <h3 class="thin underline">Modify Repayment and Reprint Receipts</h3>

                <table id="flex" style="display:none;"></table>

                <div style="display: none;">
                    <div id="form-window" style="margin: 20px 5px 5px 5px;">
                        <div class="prompt" ></div>
                        <div id="repayment_list" style="width:650px; float: left; margin-right: 20px;margin-bottom: 20px;">
                            <div class="tdDiv thflotDiv" style="overflow: auto; max-height: 300px;">
                                <table id="repayment_detail_tbl_list" class="table table-bordered thfloat">
                                    <thead>
                                    <tr>
                                        <th>Repayment Date</th>
                                        <!--<th>Amount Tendered Currency</th>-->
                                        <th>Amount</th>
                                        <th>Payment Type</th>
                                        <th>Comments</th>
                                        <th>Modify</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div id="repayment_edit_section"  style="width:400px; float: right;">
                            <div id="repayment_inner_block"  style="display:none;">
                                <?php echo $this->Form->create('SaleCreditPayment', array('default' => false, 'id' => 'form', 'action' => 'add','inputDefaults' => array('label' => false,'div' => false)));?>
                                <fieldset class="fieldset">
                                    <legend class="legend">Info</legend>

                                    <p class="button-height inline-label">
                                        <label class="label">Amount Tendered Currency:</label>
                                        <?php echo $this->Form->input('paid_amount_currency', array('div' => false, 'label' => false, 'id' => 'paid_amount_currency', 'class' => 'select', 'options' => $currency_opts, 'default' => '$')); ?>
                                        <?php echo $this->Form->input('currency', array('type'=>'hidden','div' => false, 'label' => false, 'id' => 'currency', 'class' => '', 'default' => 'GHc')); ?>
                                    </p>

                                    <p class="button-height inline-label">
                                        <label class="label">Amount Tendered:</label>
                                        <?php echo $this->Form->input('original_paid_amount', array('type' => 'text', 'div' => false, 'label' => false, 'id'=>'original_paid_amount' ,'class' => 'input validate[required,custom[number]] ', 'value'=>'0.00')); ?>
                                        <?php echo $this->Form->input('paid_amount', array('type' => 'hidden', 'div' => false, 'label' => false, 'id'=>'paid_amount' ,'class' => '', 'value'=>'0.00')); ?>
                                    </p>

                                    <p id="conversion_rate_txt" class="button-height inline-label">
                                        <label class="label">USD Conversion Rate:</label>
                                        <?php echo $this->Form->input('usd_rate', array('type' => 'text', 'div' => false, 'label' => false, 'id' => 'usd_rate', 'class' => 'input validate[required,custom[number]]', 'value' => '0.00'));  ?>
                                    </p>

                                    <p class="button-height inline-label" id="amt_tendered_rate_txt">
                                        <label class="label">Amount Tendered USD:</label>
                                        <span><b>0.00</b></span>
                                    </p>

                                    <p class="button-height inline-label">
                                        <label class="label">Date of Payment:</label>
                                        <span class="input">
                                            <?php echo $this->Form->input('pay_date', array('type'=>'text','id'=>'pay_date', 'class' => 'input-unstyled validate[required]',  'readonly' => 'readonly','div' => false, 'label' => false,)); ?>
                                            <a href="javascript:void(0)" class="button compact" id="pay_date_btn">Date</a>
                                        </span>
                                    </p>

                                    <p class="button-height inline-label">
                                        <label class="label">Payment Type:</label>
                                        <?php echo $this->Form->input('pay_type', array('id'=>'pay_type', 'class' => 'select' ,'options'=>$pay_type_opt,'div' => false, 'label' => false,)); ?>
                                    </p>


                                    <p class="button-height inline-label">
                                        <label class="label">Comments:</label>
                                        <?php echo $this->Form->input('comments', array('id'=>'comments', 'class' => 'input full-width', 'div' => false, 'label' => false,)); ?>
                                        <?php echo $this->Form->input('id', array('type'=>'hidden','div' => false, 'label' => false, 'id'=>'id')); ?>
                                    </p>

                                    <p class="button-height inline-label">
                                        <label for="save-btn" class="label">&nbsp;</label>
                                        <button type="submit" class="button" id="save-btn">
                                            <span class="button-icon green-gradient"><span class="icon-download"></span></span>
                                            Save
                                        </button>

                                        <button type="button" class="button" id="cancel-btn">
                                            <span class="button-icon anthracite-gradient"><span class="icon-cross-round"></span></span>
                                            Cancel
                                        </button>
                                    </p>


                                </fieldset>

                                <?php echo $this->Form->end();?>
                            </div>

                        </div>

                    </div>
                </div>

            </div>
        </div>
    </div>

</section>
<!-- End main content -->

<!-- Side tabs shortcuts -->
<?php echo $this->element('side_tabs_shortcuts'); ?>
<!-- Sidebar/drop-down menu -->
<?php echo $this->element('right_side_infos'); ?>


<!-- Users URL -->
<input type="hidden" id="table-url" value="<?php echo $this->Html->url(array('controller' => 'EditSales', 'action' => 'getRepayment')); ?>" />
<input type="hidden" id="add-edit-url" value="<?php echo $this->Html->url(array('controller' => 'EditSales', 'action' => 'updateRepayment')); ?>" />
<input type="hidden" id="load-user-url" value="<?php echo $this->Html->url(array('controller' => 'EditSales', 'action' => 'loadRepayment')); ?>" />
<input type="hidden" id="delete-url" value="<?php echo $this->Html->url(array('controller' => 'EditSales', 'action' => 'delete_Repayment')); ?>" />
<input type="hidden" id="print-receipt-url" value="<?php echo $this->Html->url(array('controller' => 'Sales', 'action' => 'print_receipt')); ?>" />

<!-- Images URL -->
<input type="hidden" id="edit-pic-src" value="<?php echo $this->Html->url('/img/edit.png'); ?>" />
<input type="hidden" id="delete-pic-src" value="<?php echo $this->Html->url('/img/button_delete.gif'); ?>" />
<input type="hidden" id="print-pic-src" value="<?php echo $this->Html->url('/img/icon-16s.png'); ?>" />

<?php
echo $this->Html->script('setup.js');

/** Template functions **/
echo $this->Html->script('developr.input.js');
echo $this->Html->script('developr.message.js');
echo $this->Html->script('developr.modal.js');
echo $this->Html->script('developr.navigable.js');
echo $this->Html->script('developr.notify.js');
echo $this->Html->script('developr.scroll.js');
echo $this->Html->script('developr.progress-slider.js');
echo $this->Html->script('developr.tooltip.js');
echo $this->Html->script('developr.confirm.js');
echo $this->Html->script('developr.agenda.js');
echo $this->Html->script('developr.tabs.js');

echo $this->Html->script('libs/tinycon.min.js');
echo $this->Html->script('jquery.thfloat-0.3.min.js');
echo $this->Html->script('custom-scripts/edit_repayment.js');
?>